// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1070

#define COMPILE_P1070
#ifdef COMPILE_P1070

#include <fstream>

using namespace std;

int n;
int m;

int a = 0;
int b = 0;

void input() {
	ifstream in("input.txt");

	in >> n >> m;

	in.close();
}

void solve() {
	int data[4];
	int place[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

	for (int i = 0; i < 4; i++) {
		int j = n % 10;
		data[i] = j;
		place[j] = i;
		n /= 10;
	}

	for (int k = 0; k < 4; k++) {
		int l = m % 10;
		if (place[l] != -1) {
			if (place[l] == k)
				a++;
			else
				b++;
		}
		m /= 10;
	}

}

void output() {
	ofstream out("output.txt");

	out << a << "A" << b << "B";

	out.close();
}

int main() {
	input();
	solve();
	output();
    return 0;
}


#endif
